1. Field of the Invention
The present invention relates to clipping of a basic geometry (referred to as "primitive" hereinafter) of an object to be displayed in a graphics system.
2. Description of the Background Art
In a graphics system, displaying an object needs clipping. The clipping refers to a processing for displaying only a portion of the primitive of an object to be displayed that exists within the four sides of a display window in a 2D (two-dimensional) graphics system, for example. Further, in a 3D (three-dimensional) graphics system, for example, only a portion of the primitive that exists within a view volume of rectangular solid or frustum of pyramid constituted of planes in accordance with the distance from a point of view.
FIG. 13 illustrates a concept of clipping in 3D graphics display, presenting a triangle having three vertices V0, V1 and V2. In the graphics, the primitive may be vertices V0, V1 and V2, lines V0V1, V1V2 and V2V0, or a polygon V1V2V0. These cases will be referred to as where the primitive is vertex, line or polygon, respectively, in the following discussion. FIG. 14 illustrates graphics displayed in a window after clipping.
The clipping process includes a first step of judging whether a primitive exists within or beyond a window or a view volume, a second step of detecting points of intersection between the primitive and planes constituting the window or the view volume when the result of the first step indicates "beyond" and a third step of cutting a portion of the primitive which is out of the window or the view volume.
With reference to FIGS. 15 and 16, the first step will be discussed, taking a case of rectangular-solid view volume as an example. These figures show a view volume constituted of six planes of x=-1, x=1, y=-1, y=1, z=-1 and z=1.
When the primitive is vertex, the coordinate of each vertex is compared with the values representing the six planes. As the result of comparison, a clip code is obtained, which represents whether a vertex is within or beyond the view volume as e.g., "1" or "0", respectively. Since the view volume has six planes, judgment on whether the noted vertex is within or beyond the view volume needs a clip code of 6 bits. Accordingly, if the 6 bits of the clip code are all "1", the vertex is judged to be within the view volume. In accordance with FIGS. 13 to 16, the clip codes relating to the vertices and the six planes are shown in Table 1. It can be seen from Table 1 that only the vertex V0 is within the view volume and the other vertices V1 and V2 are beyond the view volume.
TABLE 1 ______________________________________ x = 1 x = -1 y = 1 y = -1 z = 1 Z = -1 ______________________________________ V0 1 1 1 1 1 1 V1 1 1 0 1 1 1 V2 0 1 1 1 1 1 ______________________________________
When the primitive is line, each of endpoints (initial point and terminal point) needs the clip code of 6 bits. As to a line, if 12 bits of the clip code are all "1", the line is judged to be within the view volume. If any one of the 12 bits of the clip code is "0", the second step is performed, referring to the clip code, to detect the point of intersection between the line and the view volume.
When the primitive is polygon, the polygon is divided into triangles (hereinafter the primitive is triangle in a case of polygon) before the clipping. If 18 bits of the clip code relating to the three vertices of the triangle are all "1", the polygon is judged to be within the view volume. If any one of the 18 bits of the clip code is "0", the second step is performed, referring to the clip code, to detect the line of intersection between the plane and the view volume.
Thus, in the background art, preparation for generation of the clip code, i.e., comparison in position between the vertices and the planes constituting the view volume, and generation of the clip code based on the comparison result are performed in software, disadvantageously requiring a very long operation time.